max
Find the maximum value
max()
returns the maximum value.
In this example, we will use max()
to return the maximum value of the two specified numbers:
<?php echo ( max ( 5 , 7 ) ) ; echo ( max ( - 3 , 5 ) ) ; echo ( max ( - 3 , - 5 ) ) ; echo ( max ( 7.25 , 7.30 ) ) ; ?>
Try it yourself
max ( x , y )
parameter | describe |
---|---|
x | Required. A number. |
y | Required. A number. |
max()
returns the maximum value in the parameter.
If there is only one parameter and is an array, max()
returns the largest value in the array. If the first parameter is an integer, string, or floating point number, at least two parameters are required and max()
returns the largest of these values. An infinite number of values can be compared.